package com.dnjn.mes.biz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dnjn.mes.biz.domain.MesExceptPlanXref;
import com.dnjn.mes.biz.domain.MesResolvePlan;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 异常及解决方案关联表 Mapper 接口
 * </p>
 *
 * @author Amber
 * @since 2023-07-26
 */
public interface MesExceptPlanXrefMapper extends BaseMapper<MesExceptPlanXref> {

    @Delete("delete from mes_except_plan_xref where plan_id=#{planId}")
    void removeByPlanId(@Param("planId") Long planId);

    @Select("select b.plan_id,b.description,c.workpiece_name  from mes_except_plan_xref a LEFT JOIN mes_resolve_plan b ON a.plan_id = b.plan_id LEFT JOIN mes_workpiece c ON b.workpiece_id=c.workpiece_id WHERE a.except_id = #{exceptId}")
    List<MesResolvePlan> getPlanListByExceptId(@Param("exceptId") Long exceptId);
}
